<html>
	<head>
		<title>Subdistrict Search form</title>
		<link rel="stylesheet" href="style.css">
	</head>
	<body>
	
	<table id="contentTable">
		<tr>
			<td colspan="2" id="pageheader">
				health information system
			</td>
		</tr>
		<tr>
			<td id="mainnav">
				<div class="menuitem">Districts</div>
				<div class="menuitem">Sub Districts</div>
				<div class="menuitem">Communities</div>
				<!-- <div class="menuitem">nutrition</div> -->
				<div class="menuitem">CHO</div>
				<!-- <div class="menuitem">family planning</div> -->
			</td>
			<td id="content">
				<div id="divPageMenu">
					<!-- <span class="menuitem" >districts</span>
					<span class="menuitem" >sub districts</span>
					<span class="menuitem" >communities</span>
					<span class="menuitem" >view map</span> -->
					<input type="text" id="txtSearch">
					<span class="menuitem">search</span>		
				</div>
				<div id="divStatus" class="status">
					status message
				</div>
				<div id="divContent">
					<form action="subdistrict_search_form.php" method="POST">
						<table class="tableForm">
							<tr>
								<td class="label">Subdistrict Name: </td>
								<td class="field"><input type="text" name="subdistrict_name" value="Subdistrict Name"></td>
							</tr>
							<tr>
								<td></td>
								<td class="field"><input type="submit" name="submit" value="search"></td>
							</tr>
						Subdistricts
						<table class="reportTable" width="100%" >
							<tr class="header" >
								<td>Subdistrict</td>
								<td></td>
							</tr>
		<?php
		include_once("community_table_functions.php");
		
		$new_subd = new subdistrict();
		
		if(isset($_REQUEST['subdistrict_name'])){
			$subdistrictname = $_REQUEST['subdistrict_name'];
			
			if (!$new_subd->search($subdistrictname)){
				echo "error";
				exit();
			}
			
			$item = $new_subd->fetch();
			
			$row_counter=0;
			while($item){
				
				if($row_counter%2==0){
					$style=" class='row1' ";
				}else{
					$style=" class='row2' ";
				}
			
				echo "<tr $style >";
				
				echo "<td>$item[subdistrict_name]</td>";
				echo "<td><a href='subdistrict_edit_form.php?subdistrict_id=$item[subdistrict_id]'>edit</a></td>";
				
				echo "</tr>";
				$item = $new_subd->fetch();
				$row_counter++;
			}
		}
		?>
						</table>
					</form>
				</div>
			</td>
		</tr>
	</table>
		
	</body>
</html>